package com.example.aitoedu.controller.student;

import cn.dev33.satoken.annotation.SaCheckRole;
import cn.dev33.satoken.stp.StpUtil;
import cn.dev33.satoken.util.SaResult;
import com.example.aitoedu.service.StuSignService;
import com.example.aitoedu.vo.StuSignVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/student/sign")
@Slf4j
@CrossOrigin
@Tag(name = "学生端签到相关接口")
@SaCheckRole("学生")
public class StuSignController {

    @Autowired
    private StuSignService stuSignService;

    @PostMapping("/uploadPhoto")
    @Operation(summary = "上传人脸图片")
    public SaResult uploadPhoto(MultipartFile file) throws IOException {
        return stuSignService.uploadPhoto(file);
    }

    @PostMapping("/sign")
    @Operation(summary = "学生签到")
    public SaResult sign(MultipartFile file,Long signId) throws Exception {
        return stuSignService.sign(file, signId);
    }

    @GetMapping("/mySign")
    @Operation(summary = "学生查询自己所有签到信息")
    public SaResult mySign(){
        List<StuSignVO> stuSignVOList = stuSignService.mySign();
        return SaResult.ok().setData(stuSignVOList);
    }
}
